#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> PII;

int m, n;
int ret = 0;
bool visited[210][210] = { false };

int dx[4] = { 1 , -1 , 0 , 0 };
int dy[4] = { 0 , 0 , 1 , -1 };

void bfs(vector<vector<char>>& board, int i, int j)
{
    queue<PII> q;

    q.push({ i,j });
    visited[i][j] = true;

    while (!q.empty())
    {
        auto [a, b] = q.front();
        q.pop();

        for (int k = 0; k < 4; ++k)
        {
            int x = i + dx[k], y = j + dy[i];
            if (x >= 0 && x < m && y >= 0 && y < n && !visited[x][y]
                && board[x][y] == 'O')
            {
                q.push({ x,y });
                visited[x][y] = true;
            }
        }
    }

}

void solve(vector<vector<char>>& board) {
    m = board.size(), n = board[0].size();

    for (int i = 0; i < m; ++i)
    {
        if (board[i][0] == 'O' && !visited[i][0])
            bfs(board, i, 0);
        if (board[i][n - 1] == 'O' && !visited[i][n - 1])
            bfs(board, i, n - 1);
    }

    for (int j = 0; j < n; ++j)
    {
        if (board[0][j] == 'O' && !visited[0][j])
            bfs(board, 0, j);
        if (board[m - 1][j] == 'O' && !visited[m - 1][j])
            bfs(board, m - 1, j);
    }

    for (int i = 0; i < m; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (board[i][j] == 'O' && !visited[i][j])
                board[i][j] = 'X';
        }
    }
}


int main()
{

	return 0;
}